package com.hktf.uilib.bean.lock;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.hktf.corelib.utils.CommUtils;
import com.hktf.corelib.utils.Config;

public class WidgetItem implements MultiItemEntity {


    public static final int TYPE_EMPTY=-1;//空白
    public static final int TYPE_TITLE=0;//标题
    public static final int TYPE_TEXT1=1;//文本占一个位置
    public static final int TYPE_TEXT2=2;//文本占两个位置

    public static final int TYPE_GIF=3;//git动图占一个位置

    public static final int TYPE_JITANG=4;//鸡汤占两个位置

    public static final int TYPE_TEXT_CIRCLE=5;//一个字圆形文本占一个位置


    private boolean isCheck;
    private int itemType;//0正常组件（title文本+weight权重） 1标题组件（title+iconResId） 2图片组件（iconResId+weight权重）
    private int iconResId;
    private int weight;
    private String title;

    public static WidgetItem getWidgetItem(int itemType) {
        WidgetItem item = new WidgetItem();
        item.setItemType(itemType);
        switch (itemType) {
            case TYPE_EMPTY:
                break;
            case TYPE_TITLE:
                break;
            case TYPE_TEXT1:
                break;
            case TYPE_TEXT2:
                break;
            case TYPE_GIF:
                break;
        }
        return item;
    }

    public static void clone(WidgetItem src,WidgetItem target){
        //将src复制给target
        target.setCheck(src.isCheck());
        target.setItemType(src.getItemType());
        target.setIconResId(src.getIconResId());
        target.setTitle(src.getTitle());
        target.setWeight(src.getWeight());

    }

    public WidgetItem(boolean isCheck, int itemType, int iconResId, String title) {
        this.isCheck = isCheck;
        this.itemType = itemType;
        this.iconResId = iconResId;
        this.title = title;
        initWeight();
    }

    private void initWeight(){
        switch (itemType) {
            case TYPE_EMPTY:
                weight=Config.WIDGET_SPACE;
                break;
            case TYPE_TITLE:
                weight=Config.WIDGET_SPACE;
                break;
            case TYPE_TEXT1:
                weight=1;
                break;
            case TYPE_TEXT2:
                weight=2;
                break;
            case TYPE_GIF:
                weight=1;
                break;
            case TYPE_JITANG:
                weight=2;
                break;
            case TYPE_TEXT_CIRCLE:
                weight=1;
                break;
        }
    }

    public int getIconResId() {
        return iconResId;
    }

    public void setIconResId(int iconResId) {
        this.iconResId = iconResId;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public WidgetItem() {
    }

    public void setItemType(int itemType) {
        this.itemType = itemType;
    }



    public boolean isCheck() {
        return isCheck;
    }

    public void setCheck(boolean check) {
        isCheck = check;
    }

    @Override
    public int getItemType() {
        return itemType;
    }
}
